<template>
  <div class="mini-chart">
    <div class="chart-content" :style="{height: 46}">
      <v-chart :force-fit="true" :height="height" :data="dataSource" :padding="[36, 5, 18, 5]">
        <v-tooltip />
        <v-bar position="date*num" />
      </v-chart>
    </div>
  </div>
</template>

<script>
import {format} from 'date-fns'


const tooltip = [
  'date*num',
  (date, num) => ({
    name: date,
    value: num
  })
]

const scale = [{
  dataKey: 'num',
  title: '访问量',
  min:0
}, {
  dataKey: 'date',
  title: '时间',
  min:0
}]

export default {
  name: 'MiniBar',
  props:['ordersData'],
  created() {
    this.dataSource = this.ordersData.map(ele => {
      ele.date = format(new Date(ele.date), 'yyyy-MM-dd');
      return ele
    })
  },
  data () {
    return {
      dataSource:[],
      scale,
      tooltip,
      height: 100
    }
  }
}
</script>

<style lang="less" scoped>
@import "index.less";
</style>
